﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcWebRole1.Controllers
{
    public class HomeController : Controller
    {
        static PerformanceCounter _messagesCounter;
        static PerformanceCounter _errorCounter;

        static HomeController ()
	    {
            const string categoryName = "My Messages Category";

            _messagesCounter = new PerformanceCounter();
            _messagesCounter.CategoryName = categoryName;
            _messagesCounter.CounterName = "Messages received per second";
            _messagesCounter.ReadOnly = false;

            _errorCounter = new PerformanceCounter();
            _errorCounter.CategoryName = categoryName;
            _errorCounter.CounterName = "Messages with error per second";
            _errorCounter.ReadOnly = false;
	    }
        public ActionResult Index()
        {
            _messagesCounter.Increment();
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
            return View();
        }

        public ActionResult Error()
        {
            _errorCounter.Increment();
            ViewBag.Message = "Error.";
            return View("Index");
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}